home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / jovept1.arc / INTER.C < prev    next >
Text File  |  1985-05-30  |  3KB  |  130 lines

  1. /*   inter.c */
  2.  
  3. /* JOVE/MSDOS. K. Mitchum 1/85 */
  4. /* Modifications for personal use only. */
  5. /* original code J. Payne LSRHS 5/83 */
  6. /* Ken Mitchum */
  7. /* University of Pittsburgh */
  8. /* Decision Systems Laboratory */
  9.  
  10. /* contains the procedures to HELP the user by creating buffers with
  11.    information in them, or temporarily writing over the user's text. */
  12.  
  13. #include "jove.h"
  14. #include "term.h"
  15. #include "screen.h"
  16.  
  17.  
  18. #define WITHSCREEN    1
  19. #define WITHBUFFER    2
  20.  
  21. static char    *BufToUse;    /* Buffer to pop to if we are using buffers */
  22. static WINDOW    *LastW;        /* Save old window here so we can return */
  23. static BUFFER    *LastB;        /* Buffer that used to be in LastW (in case it
  24.                    isn't when we're done. */
  25. static int    Gobble,
  26.         Wrapped,
  27.         StartNo,
  28.         LineNo;        /* Line number we have reached (if we are NOT
  29.                    using buffers.  This way is MUCH easier since
  30.                    all we have to do is zero out the oimage line
  31.                    pointer and let redisplay() notice the change
  32.                    and fix it. */
  33.  
  34. static int    WhichKind;    /* Buffers or screen? */
  35.  
  36.  
  37. /* Tell With Buffers sets everything up so that we can clean up after
  38.    ourselves when we are told to. */
  39.  
  40. TellWBuffers(bname, clobber)
  41. char    *bname;
  42. {
  43.     WhichKind = WITHBUFFER;        /* So we know how to clean up */
  44.     BufToUse = bname;
  45.     LastW = curwind;
  46.     LastB = curbuf;
  47.     pop_wind(bname, clobber);    /* This creates the window and
  48.                        makes it the current window. */
  49. }
  50.  
  51. /* Tell With Screen.  If gobble is non-zero we DON'T ungetc characters as
  52.    they are typed  e.g. --more-- or at the end of the list. */
  53.  
  54. TellWScreen(gobble)
  55. {
  56.     WhichKind = WITHSCREEN;
  57.     StartNo = LineNo = FLine(curwind);    /* Much easier, see what I mean! */
  58.     Wrapped = 0;
  59.     Gobble = gobble;
  60. }
  61.  
  62. /* DoTell ... don't keep the user in suspense!
  63.    
  64.    Takes a string as an argument and displays it correctly, i.e. if we are
  65.    using buffers simply insert the string into the buffer adding a newline.
  66.    Otherwise we swrite the line and change oimage */
  67.  
  68. DoTell(string)
  69. char    *string;
  70. {
  71.     if (WhichKind == WITHBUFFER) {
  72.         exp = 1;
  73.         ins_str(string);
  74.         LineInsert();
  75.         return OKAY;
  76.     }
  77.  
  78.     if (LineNo == StartNo + curwind->w_height - 1) {
  79.         int    c;
  80.  
  81.         Wrapped++;        /* We wrapped ... see StopTelling */
  82.         LineNo = StartNo;
  83.         message("--more--");
  84.         UpdateMesg();
  85.         switch (c = getchar()) {
  86.         case ' ':
  87.             break;
  88.  
  89.         case CTL(G):
  90.         case '\177':
  91.             if (!Gobble)
  92.                 ignore(Ungetc(c));
  93.             return ABORT;
  94.  
  95.         default:
  96.             if (Gobble == 0)
  97.                 ignore(Ungetc(c));
  98.             return STOP;
  99.         }
  100.         message("");
  101.         UpdateMesg();
  102.     }
  103.     i_set(LineNo, 0);
  104.     ignore(swrite(string,0));
  105.     cl_eol();
  106.     oimage[LineNo].Line = (LINE *) -1;
  107.     LineNo++;
  108.     flusho();
  109.     return OKAY;
  110. }
  111.  
  112. StopTelling()
  113. {
  114.     if (WhichKind == WITHBUFFER) {
  115.         NotModified();
  116.         SetWind(LastW);
  117.         LastW = 0;
  118.     } else {
  119.         int    c;
  120.  
  121.         ignore(DoTell("----------"));
  122.         c = getchar();
  123.         if (c != ' ' && Gobble == 0)
  124.             ignore(Ungetc(c));
  125.     }
  126. }
  127.  
  128.  
  129. /* end */
  130.